//
//  ZJPageScrollViewController.m
//  ScrollPageView
//
//  Created by kepuna on 2017/4/12.
//  Copyright © 2017年 kepuna. All rights reserved.
//

#import "ZJPageScrollViewController.h"
#import "ZJPageTitleView.h"
#import "ZJPageContentView.h"

@interface ZJPageScrollViewController ()<ZJPageTitleViewDelegate,ZJPageContentViewDelegate>

@property (nonatomic, strong) ZJPageTitleView *titleView;
@property (nonatomic, strong) ZJPageContentView *contentView;

@end

@implementation ZJPageScrollViewController

- (instancetype)initWithPageTitleViewFrame:(CGRect)titleViewframe contentViewFrame:(CGRect)contentViewFrame {
    if (self = [super init]) {
        
        self.view.backgroundColor = [UIColor whiteColor];
        self.automaticallyAdjustsScrollViewInsets = NO;
        self.titleView = [[ZJPageTitleView alloc] initWithFrame:titleViewframe titles:self.titles];
        self.titleView.delegate = self;
        [self.view addSubview:self.titleView];
    
        
        self.contentView = [[ZJPageContentView alloc]initWithFrame:contentViewFrame childControllers:self.childControllers parentController:self];
        self.contentView.delegate = self;
        [self.view addSubview:self.contentView];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma  mark -- ZJPageTitleViewDelegate
- (void)pageTitleView:(ZJPageTitleView *)pageTitleView clickIndex:(NSInteger)index {
    [self.contentView setCurrentIndex:index];
}

#pragma  mark -- ZJPageContentViewDelegate
- (void)pageContentView:(ZJPageContentView *)pageContentView targetIndex:(NSInteger)targetIndex {
    
    [self.titleView setTitleWithTargetIndex:targetIndex];
}


@end
